<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
	<#import "/spring.ftl" as spring/> 
	<meta charset="UTF-8">
    <meta http-equiv="pragma" content="no-cache"/>
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0"> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/> 
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>慧慈天下</title>
    <link href="/assets/css/default.css" rel="stylesheet" type="text/css" />
	<!--必要样式-->
    <link href="/assets/css/styles.css" rel="stylesheet" type="text/css" />
    <link href="/assets/css/demo.css" rel="stylesheet" type="text/css" />
    <link href="/assets/css/loaders.css" rel="stylesheet" type="text/css" />
    <link href="/assets/plugins/layui/css/layui.css" rel="stylesheet" type="text/css" />
</head>
<body>
	<div class='login'>
	  <div class='login_title'>
	    <h2><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<@spring.message code="login.h2Title"/></span></h2>
	  </div>
	  <div class='login_fields'>
	    <div class='login_fields__user'>
	      <div class='icon'>
	        <img alt="" src='/assets/images/user_icon_copy.png'/>
	      </div>
	      <input name="username" placeholder='用户名' maxlength="16" type='text' autocomplete="off"/>
	        <div class='validation'>
	          <img alt="" src='/assets/images/tick.png'/>
	        </div>
	    </div>
	    <div class='login_fields__password'>
	      <div class='icon'>
	        <img alt="" src='/assets/images/lock_icon_copy.png'>
	      </div>
	      <input name="password" placeholder='密码' maxlength="16" type='text' autocomplete="off">
	      <div class='validation'>
	        <img alt="" src='/assets/images/tick.png'>
	      </div>
	    </div>
	    <div class='login_fields__password' style="display:none">
	      <div class='icon'>
	        <img alt="" src='/assets/images/key.png'>
	      </div>
	      <input name="kaptcha" placeholder='验证码' maxlength="4" type='text' name="ValidateNum" autocomplete="off">
	     <!--  <img alt="点击获取验证码" id="img-kaptcha" src="/getKaptcha" class="login-captcha" style=" position: absolute;margin-left: 150px;margin-top: -40px;"> -->
	      <div class='validation' style="opacity: 1; right: -5px;top: -3px;">
          <canvas class="J_codeimg" id="myCanvas" onclick="Code();">对不起，您的浏览器不支持canvas，请下载最新版浏览器!</canvas>
	      </div>
	    </div>
	    
<!-- 	     <div class='login_fields__password'>
	      <input type="checkbox" id="rememberMe" name="rememberMe" title="记住我" lay-skin="primary" value="1"> 
	    </div>
 -->	    
	    <div class='login_fields__submit'>
	      <input type='button' value='登录'>
	    </div>
	  </div>
	  <div class='success'>
	  </div>
	  <div class='disclaimer'>
		  <div class="layui-main">
		    <p>Copyright © ${.now?string["yyyy"]} ${licence.copyright}. All Rights Reserved.</p>
		   </div>
	  </div>
	</div>
	<div class='authent'>
	  <div class="loader" style="height: 44px;width: 44px;margin-left: 0px;">
        <div class="loader-inner ball-clip-rotate-multiple">
            <div></div>
            <div></div>
            <div></div>
        </div>
        </div>
	  <p>认证中...</p>
	</div>
	<div class="OverWindows"></div>
	
   
	
	<script type="text/javascript" src="/assets/js/jquery-1.11.1.min.js"></script>
	<script type="text/javascript" src='/assets/js/stopExecutionOnTimeout.js?t=1'></script>
    <script type="text/javascript" src="/assets/plugins/layui/layui.js"></script>
    <script type='text/javascript' src='/assets/js/jquery.particleground.js'></script>
	<script type="text/javascript">
		var canGetCookie = 0;//是否支持存储Cookie 0 不支持 1 支持
		var ajaxmockjax = 0;//是否启用虚拟Ajax的请求响 0 不启用  1 启用
		
		var CodeVal = 0;
	   // Code();
	    function Code() {
			if(canGetCookie == 1){
				createCode("AdminCode");
				var AdminCode = getCookieValue("AdminCode");
				showCheck(AdminCode);
			}else{
				showCheck(createCode(""));
			}
	    }
	    function showCheck(a) {
			CodeVal = a;
	        var c = document.getElementById("myCanvas");
	        var ctx = c.getContext("2d");
	        ctx.clearRect(0, 0, 1000, 1000);
	        ctx.font = "80px 'Hiragino Sans GB'";
	        ctx.fillStyle = "#E8DFE8";
	        ctx.fillText(a, 0, 100);
	    }
	    $(document).keypress(function (e) {
	        // 回车键事件  
	        if (e.which == 13) {
	            $('input[type="button"]').click();
	        }
	    });
	    //粒子背景特效
	    $('body').particleground({
	        dotColor: '#E8DFE8',
	        lineColor: '#133b88'
	    });
	    $('input[name="password"]').focus(function () {
	        $(this).attr('type', 'password');
	    });
	    $('input[type="text"]').focus(function () {
	        $(this).prev().animate({ 'opacity': '1' }, 200);
	    });
	    $('input[type="text"],input[type="password"]').blur(function () {
	        $(this).prev().animate({ 'opacity': '.5' }, 200);
	    });
	    $('input[name="username"],input[name="password"]').keyup(function () {
	        var Len = $(this).val().length;
	        if (!$(this).val() == '' && Len >= 5) {
	            $(this).next().animate({
	                'opacity': '1',
	                'right': '30'
	            }, 200);
	        } else {
	            $(this).next().animate({
	                'opacity': '0',
	                'right': '20'
	            }, 200);
	        }
	    });
	    var open = 0;
	    layui.use('layer', function () {
	        //非空验证
	        $('input[type="button"]').click(function () {
	            var login = $('input[name="username"]').val();
	            var pwd = $('input[name="password"]').val();
	            var code = $('input[name="kaptcha"]').val();
	            if (login == '') {
	            	var index = layer.alert('请输入您的账号', { icon: 5, time: 2000, closeBtn: 0, title: '错误信息', btn: [], anim: 2, shade: 0 });
	                layer.style(index, {
	                    color: '#777'
	                }); 
	            } else if (pwd == '') {
	            	var index = layer.alert('请输入密码', { icon: 5, time: 2000, closeBtn: 0, title: '错误信息', btn: [], anim: 2, shade: 0 });
	                layer.style(index, {
	                    color: '#777'
	                }); 
	            }/*  else if (code == '' || code.length != 4) {
	                ErroAlert('输入验证码');
	            } */ else {
	                //认证中..
	                //fullscreen();
	                $('.login').addClass('test'); //倾斜特效
	                setTimeout(function () {
	                    $('.login').addClass('testtwo'); //平移特效
	                }, 300);
	                setTimeout(function () {
	                    $('.authent').show().animate({ left: -320 }, {
	                        easing: 'easeOutQuint',
	                        duration: 600,
	                        queue: false
	                    });
	                    $('.authent').animate({ opacity: 1 }, {
	                        duration: 200,
	                        queue: false
	                    }).addClass('visible');
	                }, 500);
					
	                //登录
	                var JsonData=["username=",login,"&password=",pwd,"&kaptcha",code,"&rememberMe",true];
	                JsonData=JsonData.join('');
					
					 $.ajax({
			                type: "POST",
			                url: "/auth/signin",
			                data: JsonData,
			                dataType: "json",
			                success: function (json) {
			                    if (json.status == 200) {
			                        window.location.href = "/";
			                    }else{
			                    	
			                    	var index = layer.alert(json.message, { icon: 5, time: 2000, closeBtn: 0, title: '错误信息', btn: [], anim: 2, shade: 0 });
			    	                layer.style(index, {
			    	                    color: '#777'
			    	                }); 
			    	                setTimeout(function () {
                                        $('.authent').hide();
                                        $('.login').removeClass('test');
                                         $('.login div').fadeOut(100);
											
                                    }, 2400);
			    	                
			                    }
			                }
			            });
	            }
	        })
	    })
	    var fullscreen = function () {
	        elem = document.body;
	        if (elem.webkitRequestFullScreen) {
	            elem.webkitRequestFullScreen();
	        } else if (elem.mozRequestFullScreen) {
	            elem.mozRequestFullScreen();
	        } else if (elem.requestFullScreen) {
	            elem.requestFullscreen();
	        } else {
	            //浏览器不支持全屏API或已被禁用  
	        }
	    }  
    </script>

</body>
</html>
